<?php
	include 'database.php';
	session_start();

	$_SESSION['trafo'] = isset($_REQUEST['trafo']) ? $_REQUEST['trafo'] : '';
	//$_SESSION['nombre_estacion'] = isset($_REQUEST['nombre_estacion']) ? $_REQUEST['nombre_estacion'] : '';
	
	$id_trafo =isset($_REQUEST['trafo']) ? $_REQUEST['trafo'] : '';
	$link = pg_connect("user=".DB_USER." port=".DB_PORT." dbname=".DB_NAME." host=".DB_HOST." password=".DB_PASS);
	
	try
	{
		$sql = "SELECT * FROM datos_ande.v_trafos WHERE gid = '".$id_trafo."'";
		
		$result = pg_exec($link, $sql);
		
		$arr = array();
		
		If (!$result) {
			pg_close($link);
			Echo '{success:false}'.$sql;
		}
		else
		{
			while($obj = pg_fetch_object($result)){
				$arr = $obj;
			}
			pg_close($link);
			Echo '{success:true,data:'.json_encode($arr).'}';		
		}
	}catch(Exception $e)
	{
		pg_close($link);
		echo '{success:false}';
	}
?>




		